/**
 * 当售价重新设置价格组时，返回的表格数据需要塞入初始关联商品数据的归属部门字段，进行对应的回显
 * 后端在设置价格组接口返回表格数据的接口中给返回归属部门字段比较耗费性能，故而放在前端来做
 */
export const getIncludesAuthDepartData = (data) => {
  let {
    tableData,
    updateList
  } = data
  let sourceList = _.cloneDeep(tableData)
  let result = updateList.reduce((value, item) => {
    let target = _.find(sourceList, elem => {
      return elem.nowInput.productUuid === item.nowInput.productUuid
    })
    item.nowInput.authDepartments = target && target.nowInput.authDepartments
    value.push(item)
    return value
  }, [])
  return result
}
